<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>先花花</title>
    
</head>
<body>
<!-- <div class="loading"><img src="images/ajax-loader.gif"/></div> -->
<div data-role="page" class="touzi tixian" id="chong">
<!--jqmb需要把所以东西放在page div内-->
 <link rel="stylesheet" href="css/jquery.mobile-1.4.5.min.css"/>
     <link rel="stylesheet" href="css/style.css"/>
     
    <!--jqmb需要把所以东西放在page div内--> 
<header data-role="header" data-position="fixed">
    <a href="javascript:history.back(-1)" data-rel="back" class="ui-btn ui-icon-carat-l ui-btn-icon-left ui-nodisc-icon" data-transition="slide" data-direction="revserse">返回</a> 
    <h3>还款</h3>
</header>
<div class="ui-content" data-role="content">
    <ul class="tibox">
        <li>
            <label>还款金额：</label>
            <input id="num" type="num" data-role="none" disabled value="00.00"/>
        </li>
        <li style="display: none">
            <label>余额：</label>
            <input type="bankType" id="bankType" data-role="none" disabled value=""/>
        </li>
        <li>
            <label>支付密码：</label>
             <div class="pwd-box">  
                <input type="tel" maxlength="6" class="pwd-input" id="pwd-input" data-role="none">  
                <div class="fake-box">  
                    <input type="password" class="password" data-role="none" maxlength="1" readonly="">  
                    <input type="password" class="password" data-role="none" maxlength="1" readonly="">  
                    <input type="password" class="password" data-role="none" maxlength="1" readonly="">  
                    <input type="password" class="password" data-role="none" maxlength="1" readonly="" >  
                    <input type="password" class="password" data-role="none" maxlength="1" readonly="" >  
                    <input type="password" class="password" data-role="none" maxlength="1" readonly="" >  
                </div>  
            </div>  
        </li>
    </ul>
    <div class="tou-sub"><input id="submit" type="submit" value="提交" data-role="none"/>
                </div>
</div>
<script src="script/jquery.js"></script>
<script src="script/jquery.cookie.js"></script>
<script src="script/jquery.md5.js"></script>
    <script src="script/jquery.mobile-1.4.5.min.js"></script>
    <script type="text/javascript">
    var storage=window.localStorage;
        //获取用户 id
        uid = $.cookie("userid");
        periods = storage["periods"];
        b_id = storage["b_id"];
        money = storage["money"];
        appid = $.md5("123");
        appkey = $.md5("1aaaa");
        pwd = '';
        $(function(){
            $("#num").val(money);
            $("#submit").click(function(){
                $(".password").each(function(k,v){
                    pwd+=v.value;
                })
                pwd = $.md5(pwd);
                 $.ajax({
                  url:"http://47.93.21.169/old/TP5/public/index.php/index/Userinfo/refund",
                  data:{appid:appid,appkey:appkey,uid:uid,periods:periods,b_id:b_id,money:money,pwd:pwd},
                  type:"get",
                  dataType:"jsonp",
                  jsonp:"callback",
                  success:function(result){
                    alert("还款成功");
                    window.location.href = 'user.html';
                  }
              });
            });
        });

     var $input = $(".fake-box input");  
    $("#pwd-input").on("input", function() {  
        var pwd = $(this).val().trim();  
        for (var i = 0, len = pwd.length; i < len; i++) {  
            $input.eq("" + i + "").val(pwd[i]);  
        }  
        $input.each(function() {  
            var index = $(this).index();  
            if (index >= len) {  
                $(this).val("");  
            }  
        });  
        if (len == 6) {  
            $(".tou-sub input").css({backgroundColor:"#009dd9"})
        }  
    }); 

    </script>  
    </div>
    
</body>
</html>